Pythagorean TriplesIntroductionA right‑angled triangle has one angle equal to $90^\circ$.The side opposite the right angle is the hypotenuse.A Pythagorean triple is a set of three positive integers $(a,b,c)$ satisfying $$a^2 + b^2 = c^2.$$These triples describe all right‑angled triangles with integer side lengths.This article explores:What Pythagorean triples areHow to find themHow to generate all of them using a simple formulaWhy the formula worksRight‑Angled Triangles and the Pythagorean EquationFor any right‑angled triangle: $$\text{(adjacent)}^2 + \text{(opposite)}^2 = \text{(hypotenuse)}^2.$$If the sides are integers, we are solving the Diophantine equation: $$a^2 + b^2 = c^2.$$We usually assume:$a$ and $b$ are the adjacent and opposite sides$c$ is the hypotenuse$a \le b < c$What Is a Pythagorean Triple?A triple $(a,b,c)$ of positive integers with $a^2 + b^2 = c^2$.Examples:$(3,4,5)$$(5,12,13)$$(8,15,17)$These are not coincidences—there is structure behind them.Famous Examples and PatternsCommon small triples:$(3,4,5)$$(6,8,10)$$(9,12,15)$$(5,12,13)$$(7,24,25)$Observations:Many triples seem to be “scaled‑up” versions of smaller ones.The hypotenuse is often just slightly larger than the longer leg.Odd numbers often appear in pairs like $(m^2 - n^2, 2mn)$.Primitive vs. Non‑Primitive TriplesA triple is primitive if $\gcd(a,b,c) = 1$.Otherwise it is non‑primitive.Examples:$(3,4,5)$ is primitive.$(6,8,10)$ is non‑primitive because all numbers share a factor of $2$.Every non‑primitive triple is a multiple of a primitive one.Generating Triples by ScalingIf $(a,b,c)$ is a triple, then so is $(ka, kb, kc)$ for any integer $k \ge 1$.Example:Start with $(3,4,5)$.Multiply by $k=3$ to get $(9,12,15)$.This explains many of the “bigger” triples we see.A First Method: Trial, Error, and PatternsTry small values of $a$ and $b$ and check whether $a^2 + b^2$ is a perfect square.Example:$3^2 + 4^2 = 9 + 16 = 25 = 5^2$.Patterns that help:If $a$ is odd, $a^2$ is odd.If $a$ is even, $a^2$ is even.$c$ must be larger than both $a$ and $b$.This method works but is slow.A Better Method: Using Algebraic RearrangementsRewrite the equation: $$a^2 = c^2 - b^2 = (c-b)(c+b).$$ This suggests:Choose two numbers $u = c-b$ and $v = c+b$.Then $a^2 = uv$.Since $u$ and $v$ have the same parity, we can set:$u = m-n$$v = m+n$This leads naturally to Euclid’s formula.Euclid’s Formula for All Primitive TriplesFor integers $m > n > 0$:Let $$a = m^2 - n^2$$ $$b = 2mn$$ $$c = m^2 + n^2.$$Then $(a,b,c)$ is a Pythagorean triple.If:$\gcd(m,n)=1$$m$ and $n$ have opposite parity (one even, one odd)then the triple is primitive.Examples:$m=2$, $n=1$: $(3,4,5)$$m=3$, $n=2$: $(5,12,13)$$m=4$, $n=1$: $(15,8,17)$ (order of $a,b$ doesn’t matter)Understanding Why Euclid’s Formula WorksKey ideas:Start with the identity: $$(m^2 - n^2)^2 + (2mn)^2 = (m^2 + n^2)^2.$$Expand both sides:Left side becomes $$m^4 - 2m^2n^2 + n^4 + 4m^2n^2 = m^4 + 2m^2n^2 + n^4.$$Right side is $$m^4 + 2m^2n^2 + n^4.$$Both sides match exactly.So the triple $$(m^2 - n^2,\; 2mn,\; m^2 + n^2)$$ always satisfies the Pythagorean equation.This identity is the algebraic heart of the formula.Parity Conditions and CoprimalityTo ensure primitiveness:$m$ and $n$ must not share a common factor.If both are odd:$a = m^2 - n^2$ is even$b = 2mn$ is evenSo the triple is not primitive.If one is even and one is odd:Exactly one of $a$ or $b$ is even.This gives a primitive triple.Classifying All Pythagorean TriplesEvery Pythagorean triple is of the form: $$(ka, kb, kc)$$ where $(a,b,c)$ is primitive and generated by Euclid’s formula.Thus:Primitive triples ↔ pairs $(m,n)$ with:$m>n$$\gcd(m,n)=1$$m$ and $n$ of opposite parityAll triples ↔ multiply primitive ones by $k$.This gives a complete classification.Connections to Geometry and Number TheoryGeometryInteger right triangles appear in construction, surveying, and design.The unit circle equation $x^2 + y^2 = 1$ relates to normalized triples.Number TheorySolving $a^2 + b^2 = c^2$ is a classic Diophantine problem.Links to:Sums of two squaresGaussian integersModular arithmeticPrimitive lattice points on circlesHistoryKnown to the Babylonians (tablet Plimpton 322).Studied by Euclid, Diophantus, and many later mathematicians.Applications and Historical NotesApplicationsComputer graphics (grid‑aligned distances)Cryptography (structure of integer solutions)Architecture and engineeringPuzzle design and recreational mathematicsHistorical NotesThe triple $(3,4,5)$ appears in ancient Egyptian rope‑stretching.Euclid’s formula is over 2000 years old.Pythagorean triples are one of the earliest studied integer patterns.CalculatorCoprimeChecks if a set of numbers are coprime with each otherE.g. if $\gcd(a, b, c) = 1$coprime(3, 4) coprime([3, 4, 5])Generating triplesWe can define a custom function for finding Pythagorean triplespythagTriple(m, n) = [m^2 - n^2, 2*m*n, m^2 + n^2] pythagTriple(2, 1) pythagTriple(3, 2)ExercisesTry these to reinforce the ideas:Verify that $(8,15,17)$ is a Pythagorean triple.SolutionVerify that $(8,15,17)$ is a Pythagorean triple.Compute:$8^2 = 64$$15^2 = 225$$17^2 = 289$Check: $$8^2 + 15^2 = 64 + 225 = 289 = 17^2.$$So $8^2 + 15^2 = 17^2$, and $(8,15,17)$ is a Pythagorean triple.Determine whether $(9,40,41)$ is primitive.SolutionDetermine whether $(9,40,41)$ is primitive.First check it is a triple:$9^2 = 81$$40^2 = 1600$$41^2 = 1681$ $$9^2 + 40^2 = 81 + 1600 = 1681 = 41^2.$$Now check $\gcd(9,40,41)$:$\gcd(9,40) = 1$ (since $9$ is $3^2$ and $40$ has prime factors $2$ and $5$).$\gcd(9,41) = 1$ (41 is prime and not $3$).$\gcd(40,41) = 1$ (consecutive integers).So $\gcd(9,40,41) = 1$, and the triple is primitive.Generate a triple using Euclid’s formula with $m=5$, $n=2$.SolutionGenerate a triple using Euclid’s formula with $m=5$, $n=2$.Using: $$a = m^2 - n^2,\quad b = 2mn,\quad c = m^2 + n^2,$$ we get:$a = 5^2 - 2^2 = 25 - 4 = 21$$b = 2 \cdot 5 \cdot 2 = 20$$c = 5^2 + 2^2 = 25 + 4 = 29$So $(21,20,29)$ is a Pythagorean triple (often written as $(20,21,29)$).Quick check: $$20^2 + 21^2 = 400 + 441 = 841 = 29^2.$$Find all triples obtained by scaling $(3,4,5)$ with $k=2,3,4$.SolutionFind all triples obtained by scaling $(3,4,5)$ with $k=2,3,4$.For $k=2$: $$(2\cdot 3, 2\cdot 4, 2\cdot 5) = (6,8,10)$$For $k=3$: $$(3\cdot 3, 3\cdot 4, 3\cdot 5) = (9,12,15)$$For $k=4$: $$(4\cdot 3, 4\cdot 4, 4\cdot 5) = (12,16,20)$$Each is a Pythagorean triple because $$(k\cdot 3)^2 + (k\cdot 4)^2 = k^2(3^2 + 4^2) = k^2 \cdot 5^2 = (k\cdot 5)^2.$$Show that if $(a,b,c)$ is primitive, then exactly one of $a$ or $b$ is even.SolutionShow that if $(a,b,c)$ is primitive, then exactly one of $a$ or $b$ is even.Suppose both $a$ and $b$ are odd.Then $a^2 \equiv 1 \pmod{4}$ and $b^2 \equiv 1 \pmod{4}$.So $a^2 + b^2 \equiv 1 + 1 = 2 \pmod{4}$.But any square is $0$ or $1 \pmod{4}$, so $c^2$ cannot be $2 \pmod{4}$—contradiction.Suppose both $a$ and $b$ are even.Then $2$ divides $a$ and $b$, and from $a^2 + b^2 = c^2$, $2$ also divides $c$.So $\gcd(a,b,c) \ge 2$, contradicting primitiveness.Therefore, $a$ and $b$ cannot both be odd or both be even.So exactly one of $a$ or $b$ is even.Find a pair $(m,n)$ that generates the triple $(7,24,25)$.SolutionFind a pair $(m,n)$ that generates the triple $(7,24,25)$.We want: $$a = m^2 - n^2,\quad b = 2mn,\quad c = m^2 + n^2 = 25.$$Solve $m^2 + n^2 = 25$ with integers:Possible pairs: $(m,n) = (4,3)$ or $(3,4)$ (up to sign).Try $m=4$, $n=3$:$m^2 - n^2 = 16 - 9 = 7$$2mn = 2 \cdot 4 \cdot 3 = 24$This matches $(7,24,25)$.So one suitable pair is $(m,n) = (4,3)$.Explain why $m$ and $n$ cannot both be even in Euclid’s formula.SolutionExplain why $m$ and $n$ cannot both be even in Euclid’s formula.If $m$ and $n$ are both even, write $m = 2m'$, $n = 2n'$.Then:$a = m^2 - n^2 = 4m'^2 - 4n'^2 = 4(m'^2 - n'^2)$$b = 2mn = 2 \cdot 2m' \cdot 2n' = 8m'n'$$c = m^2 + n^2 = 4m'^2 + 4n'^2 = 4(m'^2 + n'^2)$So $a$, $b$, and $c$ are all multiples of $4$.Hence $\gcd(a,b,c) \ge 4$, so the triple is not primitive.For generating primitive triples, $m$ and $n$ cannot both be even.List all primitive triples with $c < 30$.SolutionList all primitive triples with $c < 30$.We use Euclid’s formula with $m>n$, $\gcd(m,n)=1$, and opposite parity.Check small $m$:$m=2$, $n=1$:$(3,4,5)$, $c=5 < 30$, primitive.$m=3$, $n=2$:$(5,12,13)$, $c=13 < 30$, primitive.$m=4$, $n=1$:$(15,8,17)$ → $(8,15,17)$, $c=17 < 30$, primitive.$m=4$, $n=3$:$\gcd(4,3)=1$, opposite parity:$(7,24,25)$, $c=25 < 30$, primitive.$m=5$, $n=2$:$(21,20,29)$, $c=29 < 30$, primitive.$m=5$, $n=4$:$(9,40,41)$ has $c=41 \ge 30$, so ignore.$m=6$:With $n=1$: $(35,12,37)$, $c=37 \ge 30$.Larger $n$ give even bigger $c$.So the primitive triples with $c < 30$ are:$(3,4,5)$$(5,12,13)$$(8,15,17)$$(7,24,25)$$(20,21,29)$(You can reorder legs if desired.)Prove that $c$ is always odd in a primitive triple.SolutionProve that $c$ is always odd in a primitive triple.Let $(a,b,c)$ be primitive with $a^2 + b^2 = c^2$.From Exercise 5, exactly one of $a$ or $b$ is even.So one is even, one is odd.Then:Even square $\equiv 0 \pmod{4}$.Odd square $\equiv 1 \pmod{4}$.So $a^2 + b^2 \equiv 0 + 1 = 1 \pmod{4}$.Hence $c^2 \equiv 1 \pmod{4}$.The only integers with square $\equiv 1 \pmod{4}$ are odd integers.Therefore, $c$ must be odd.10. Challenge: Find a triple where the legs differ by $1$ (i.e., $b = a+1$).We want integers $a$ and $c$ such that: $$a^2 + (a+1)^2 = c^2.$$Expand: $$a^2 + a^2 + 2a + 1 = c^2$$ $$2a^2 + 2a + 1 = c^2.$$Try small $a$:$a=3$: $2\cdot 9 + 6 + 1 = 18 + 6 + 1 = 25 = 5^2$.So $a=3$, $b=4$, $c=5$ works.Thus $(3,4,5)$ is a Pythagorean triple whose legs differ by $1$.Challenge: Find a triple where the legs differ by $1$ (i.e., $b=a+1$).